package com.controller;

import com.entity.Student;
import com.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class StudentController {

    @Autowired
    private StudentService studentservice;

    @RequestMapping("/abcd")
    public List<Student> getStudent(){
        return studentservice.findAll();
    }

    @RequestMapping("/addStudent")
    public String addStudent(@RequestBody Student student){
        int i=studentservice.addStudent(student);
        return i>0?"success":"error";
    }

    @RequestMapping("/deleteStudent")
    public String deleteStudent(String sno){
        int i=studentservice.deleteStudent(sno);
        return i > 0 ? "error":"success";
    }
}
